package com.javabasic.algorithm.leetcode;

/**
 * @author mir.xiong
 * @version 1.0
 * @description
 * @see
 * @since Created by work on 2022/6/10 22:27
 */
public class QueriesOnNumberOfPointsInsideACircle {

    /**
     * 暴力解法
     * @param points
     * @param queries
     * @return
     */
    public int[] countPoints(int[][] points, int[][] queries) {
        int len = queries.length;
        int pointSize = points.length;

        int[] result = new int[len];
        int squareR;
        int num;
        for (int i = 0; i < len; i++) {
            squareR = queries[i][2] * queries[i][2];
            num = 0;
            for (int j = 0; j < pointSize; j++) {
                if (calculateLen(points[j][0], points[j][1], queries[i][0], queries[i][1]) <= squareR) {
                    num++;
                }
            }
            result[i] = num;
        }

        return result;
    }

    private int calculateLen(int x1, int y1, int x2, int y2) {
        int x = Math.abs((x1 - x2));
        int y = Math.abs((y1 - y2));
        return x*x + y*y;
    }
}
